<script type="text/javascript">
$(function(){
	var pg = App.base.appList.ui , pp = pg.params
		, gd = pg.seek('grid'),
	projPg=pp.ctxPg?App.base[pp.ctxPg].ui:App.base.projIndex.ui;
		
	gd.mac('grid', {
		key: 'id',
		cols: [{
			field: 'name', title : '应用名称 ', width: 200,
			render: function(r, tr){
				return $('<span class="a"></span>').click(function(){
					if(App.logon.power('app.save')){
						App.show({
							title:'应用信息',
							ctx: 'base',
							action:'appEdit',
							model: true,
							params: r
						},function(r, s){
							App.show({
								ctx: 'base',
								action: 'projIndex',
								params: $.extend(projPg.params,{defaultTab:'appPl'})
							}, $.noop, projPg);
						}, projPg);
					}
				}).append(r.name);
			}
		},{
			field: 'code', title : '英文编码', width: 200
		},{
			field: 'memo', title : '备忘录 ', width: 220
		},{
			field: 'status', title : '状态', width: 80,
			render: function(r) {
				return Cache.base.server.status[r.status];
			}
		},{
			field: 'id', title : '操作', width: 120,
			render: function(r) {
				var p = $('<div></div>');
				if (r.status == 0) {
					$('<span class="a center" style="width:100%"></span>').click(function(){
							$.post(App.ctx + '/app/start.do', {
								ids: r.id,
								status: 1 
							}, function(rs){
								pg.callback(pg.params.id);
								gd.load();
							});
					}).append('启用').appendTo(p);
				} else if (r.status == 1) {
					$('<span class="a center" style="width:100%"></span>').click(function(){
							$.post(App.ctx + '/app/stop.do', {
								ids: r.id,
								status: 0 
							}, function(rs){
								pg.callback(pg.params.id);
								gd.load();
							});
					}).append('停用').appendTo(p);
				}
				return p;
			}
		}],
		loader: {
			url: App.ctx + '/app/list.do',
			params: {
				pageNo: 1, pageSize: 10,
				id: pg.params.id
			},
			autoLoad: true
		},
		pagerLength: 10
	});

	pg.seek('key').keydown(function(e) {
		if (e.keyCode == 13)
			gd.load({ key: $(this).val() });
	});
	pg.seek('find').click(function(e) {
		gd.load({
			key: pg.seek('key').val()
		});
	});
	
	function adjust(){
		var h = pg.parent().parent().height();
		pg.height(h);
		gd.parent().height(h-50);
		gd.adjust();
	}
	$(window).resize(adjust);
	adjust();
});
</script>
<div class="head">
	<span>&nbsp;&nbsp;&nbsp;&nbsp; 关键字：</span>
	<input type="text" name="key" />
	<button name="find">查找</button>
</div>
<div class="body">
	<div class="grid" name="grid"></div>
</div>